﻿'use strict';
var data1 = [{
    "id": 1,
    "firstName": "Superman",
    "lastName": "Yoda"
}, {
    "id": 2,
    "firstName": "Foo",
    "lastName": "Whateveryournameis"
}, {
    "id": 3,
    "firstName": "Toto",
    "lastName": "Titi"
}, {
    "id": 4,
    "firstName": "Luke",
    "lastName": "Kyle"
}, {
    "id": 5,
    "firstName": "bads",
    "lastName": "dwer"
}, {
    "id": 6,
    "firstName": "qwer",
    "lastName": "zxcv"
}
];
app.controller('DataTableCtrl', function ($scope,$http) {
    // $http.get('http://localhost:63342/angular/lib/jquery/datatable/data.json').success(function(data){
    //     $scope.goods_informations = data.aaData;
    // })
    $scope.goods_informations = data1;
    $scope.data2={id:"",firstName:"",lastName:""};
    $scope.removePerson = function(index) {
        console.log(index,$scope.goods_informations[index])
        $scope.goods_informations.splice(index, 1);
        // $http.post('http://localhost:63342/angular/lib/jquery/datatable/data.json',$scope.goods_informations).success(function(data){
        //     console.log(data)
        // })
    }
    $scope.addPerson=function(u){
        $scope.data2 = u
        $scope.goods_informations.push($scope.data2);
        $scope.data2 = ""
    }
    $scope.modifyPerson=function(index) {
        $scope.goods_informations.splice(index, 1, angular.copy($scope.person2Add));
        $scope.person2Add = _buildPerson2Add($scope.person2Add.id + 1);
    }
    $scope.simpleTableOptions = {
        "sDom": "Tflt<'row DTTTFooter'<'col-sm-6'p>>",
        "iDisplayLength": 10,
        "language": {
            "search": "",
            "sLengthMenu": "_MENU_",
            "oPaginate": {
                "sPrevious": "上一页",
                "sNext": "下一页"
            }
        },
        "aaSorting": []
    };
});